﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using RooHui.Infrastructure.Entities.Repository;
using RooHui.Infrastructure.Entities.Enum;

namespace RooHui.Infrastructure.Entities.Entity
{
    public class OrderPolicy : IAccessible<P_OrderPolicy, OrderPolicy>, ILogicEntity<P_OrderPolicy, OrderPolicy>
    {
        public int Id { get; set; }
        public int OrderId { get; set; }
        public int PolicyId { get; set; }
        public PolicyAddType AddType { get; set; }
        public int RefId { get; set; }


        protected override void Covariant(P_OrderPolicy model)
        {
            if (model != null)
            {
                this.Id = model.Id;
                this.OrderId = model.OrderId;
                this.PolicyId = model.PolicyId;
                this.AddType = (PolicyAddType)model.AddType;
                this.RefId = model.RefId;
            }
        }

        protected override P_OrderPolicy Inverter(OrderPolicy model)
        {
            if (model != null)
            {
                return new P_OrderPolicy()
                {
                    AddType = (int)model.AddType,
                    Id = model.Id,
                    OrderId = model.OrderId,
                    PolicyId = model.PolicyId,
                    RefId = model.RefId
                };
            }
            return null;
        }

        public OrderPolicy Set(P_OrderPolicy dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
